package com.yesido.springcloud.controller;

import com.yesido.pojo.User;
import com.yesido.springcloud.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @program: my-study
 * @description:
 * @author: yuliang
 * @create: 2021-06-07 16:10
 */
@RestController
@RequestMapping("/pd1")
@Slf4j
public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping("/findUserById/{id}")
    public User findAllUsers( @PathVariable("id") int id ){
        return userService.findUserById(id);
    }
    /**
     * 查询所有
     */
    @GetMapping("/findAllUsers")
    public List<User> findAllUsers(){
       return userService.findAllUsers();
    }



    @PostMapping("/addUser")
    public int findAllUsers( User user){
        return userService.addUser(user);
    }
}